<?php
namespace app\api\model\operation;
use think\facade\Db;
class Focus{
	public function findFocus($_where,$_field)
	{
		return Db::name("user_focus")->where($_where)->field($_field)->find();
	}
	
	public function updateFocus($_up,$_where)
	{
		return Db::name("user_focus")->where($_where)->update($_up);
	}
	
	public function insertFocus($_data){
		return Db::name("user_focus")->insert($_data,true);
	}
	
	public function findMyFocus($_where,$_field){
		return Db::name("user_focus")->alias("f")
			->join("user u","f.focus_id=u.id")
			->leftJoin("user_focus ff","ff.focus_id=f.user_id and ff.user_id=f.focus_id")
			->where($_where)
			->field($_field)
			->find();
	}
	
	public function selectMyFocus($_where,$_field,$_limit,$_order)
	{
		$_data=Db::name("user_focus")->alias("f")
				->join("user u","f.focus_id=u.id")
				->leftJoin("user_focus ff","ff.focus_id=f.user_id and ff.user_id=f.focus_id")
				->where($_where)
				->field($_field)
				->limit(current($_limit),end($_limit))
				->order($_order)
				->select();
		return !empty($_data)?$_data->toArray():[];			
	}
	
	public function findMyFans($_where,$_field){
		return Db::name("user_focus")->alias("f")
			->join("user u","f.user_id=u.id")
			->leftJoin("user_focus ff","ff.focus_id=f.user_id and ff.user_id=f.focus_id")
			->where($_where)
			->field($_field)
			->find();
	}
	
	public function selectMyFans($_where,$_field,$_limit,$_order)
	{
		$_data=Db::name("user_focus")->alias("f")
				->join("user u","f.user_id=u.id")
				->leftJoin("user_focus ff","ff.focus_id=f.user_id and ff.user_id=f.focus_id")
				->where($_where)
				->field($_field)
				->limit(current($_limit),end($_limit))
				->order($_order)
				->select();
		return !empty($_data)?$_data->toArray():[];	
	}
}
?>